package com.hxzy.research.controller.front;

import com.hxzy.research.pojo.TblBigitem;
import com.hxzy.research.pojo.TblItem;
import com.hxzy.research.pojo.TblSelectvalue;
import com.hxzy.research.service.pageandmanager.FrontTeach;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping(value = "/front")
public class FrontCareerController {
    @Autowired private FrontTeach frontTeach;//调用的是教学效果service接口
    @RequestMapping("/career.go")
    public String findCareer(Model model, Integer pageId, Integer localId, HttpSession session) throws Exception{
        session.setAttribute("branchId",localId);
        //创就业评价中查班级 掉用的是教学态度中的方法
        model.addAttribute("classList",frontTeach.findClassByid(localId));
        //根据pageid查大项
        List<TblBigitem> bigitems= frontTeach.findBigitemByPageid(pageId);  //大项
        //通过大项id查询小项
        for (TblBigitem bigitem:bigitems){
            List<TblItem> itemList= frontTeach.findItemByBigId(bigitem.getId());
            bigitem.setSubItemVOList(itemList);

            for (TblItem item:itemList){
                List<TblSelectvalue> selectvalueList= frontTeach.findSelectvalueById(item.getId());
                item.setSelectValueVOList(selectvalueList);

            }
        }
        model.addAttribute("bigItems",bigitems);
        return "front/career";
    }
}
